package com.gxkj.movie.config;

import com.gxkj.movie.filters.LogFilter;
import com.gxkj.movie.filters.TraceIdFilter;
import org.springframework.boot.web.servlet.FilterRegistrationBean;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;


@Configuration
public class WebConfig {
    @Bean
    public FilterRegistrationBean traceFilterResg() {

        FilterRegistrationBean filterRegistrationBean = new FilterRegistrationBean();
        TraceIdFilter traceIdFilter = new TraceIdFilter();
        filterRegistrationBean.setFilter(traceIdFilter);
        //配置过滤规则
        filterRegistrationBean.addUrlPatterns("/*");
        filterRegistrationBean.setOrder(1);
        return filterRegistrationBean;
    }
    @Bean
    public FilterRegistrationBean reqResFilter() {
        FilterRegistrationBean filterRegistrationBean = new FilterRegistrationBean();
        LogFilter logFilter = new LogFilter();
        filterRegistrationBean.setFilter(logFilter);
        //配置过滤规则
        filterRegistrationBean.addUrlPatterns("/*");
        filterRegistrationBean.setOrder(2);
       return filterRegistrationBean;
    }


}